<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="../../resources/js-test.js"></script>
<script src="resources/utilities.js"></script>
</head>
<body>

<script>
description("Canonical URL should have a lowercase hostname for server based protocols.")

var protocolTestSet = [
    ['ws', true],
    ['wss', true],
    ['ftp', true],
    ['wss', true],
    ['http', true],
    ['file', true],
    ['https', true],
    ['ghost', false]];

var urls = ['lowercase', 'CamelCase', 'UnicodeFête'];
var urlExpectationsLowercase = ['lowercase', 'camelcase', 'xn--unicodefte-t7a'];
var urlExpectationsUppercase = ['lowercase', 'CamelCase', 'UnicodeF%C3%AAte'];


for (var protocolIndex = 0; protocolIndex < protocolTestSet.length; ++protocolIndex) {
    var protocol = protocolTestSet[protocolIndex][0];
    var hostnameShouldBeLowercase = protocolTestSet[protocolIndex][1];

    for (var urlIndex = 0; urlIndex < urls.length; ++urlIndex) {
        var url = protocol + '://' + urls[urlIndex] + '/';
        src = canonicalize(url);

        if (hostnameShouldBeLowercase)
            expected = protocol + '://' + urlExpectationsLowercase[urlIndex] + '/';
        else
            expected = protocol + '://' + urlExpectationsUppercase[urlIndex] + '/';

        shouldBe('src', 'expected');
    }
}

successfullyParsed = true;
</script>
</body>
</html>
